{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "763f11c4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C语言中文网 的网址为: http://c.biancheng.net\n",
      "Success to open camera\n",
      "member of frame.shape: \n",
      "(480, 640, 3)\n",
      "['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index']\n",
      "(480, 640)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "w,h = 100,200\n",
    "imgGetOnce = False\n",
    "count = 0\n",
    "\n",
    "class CLanguage:\n",
    "    '''这是一个学习Python定义的一个类'''\n",
    "    cba = \"cba\"\n",
    "    def __init__(self,name,add):\n",
    "        print(name,\"的网址为:\",add)\n",
    "    def pvc(self,name,add):\n",
    "        print(name,\"的网址为:\",add)\n",
    "#创建 add 对象，并传递参数给构造函数\n",
    "add = CLanguage(\"C语言中文网\",\"http://c.biancheng.net\")\n",
    "\n",
    "cap = cv.VideoCapture(0)\n",
    "\n",
    "\n",
    "\n",
    "if not cap.isOpened():\n",
    "    print(\"Cannot open camera\")\n",
    "    exit()\n",
    "else:\n",
    "    print(\"Success to open camera\")\n",
    "while True:\n",
    "    # Capture frame-by-frame\n",
    "    ret, frame = cap.read()\n",
    "    \n",
    "    # if frame is read correctly ret is True\n",
    "    if not ret:\n",
    "        print(\"Can't receive frame (stream end?). Exiting ...\")\n",
    "        break\n",
    "    else:\n",
    "        if not imgGetOnce:\n",
    "            print(\"member of frame.shape: \")\n",
    "            print(frame.shape)\n",
    "            print(dir(frame.shape))\n",
    "            \n",
    "            gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)\n",
    "            print(gray.shape)\n",
    "\n",
    "            imgGetOnce = True\n",
    "#             break\n",
    "\n",
    "    #draw dynamic circle\n",
    "    if count < 100:\n",
    "        cv.circle(frame,(240,320), 50+count, (0,0,255), -1)\n",
    "        count = count + 1\n",
    "        if count >= 100:\n",
    "            count = 50\n",
    "            \n",
    "    # Our operations on the frame come here\n",
    "#     gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)\n",
    "    # Display the resulting frame\n",
    "    cv.imshow('frame', frame)\n",
    "    \n",
    "    if cv.waitKey(1) == ord('q'):\n",
    "        break\n",
    "# When everything done, release the capture\n",
    "cap.release()\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2ae0b736",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
